<?php

namespace app\model;

use think\Db;

class DriverInfo extends LoginCommon
{
    protected static $obj;

    public function _initialize()
    {
        parent::_initialize();
        $this->db_name = 'driver_info';
    }

    /**
     * 类入口
     * @return DriverInfo
     */
    public static function getInstance()
    {
        if (is_null(self::$obj))
            self::$obj = new self();
        return self::$obj;
    }

    /**
     * 快速注册
     */
    public function fastRegister($str_mobile)
    {
        $arr_data = [
            'mobile' => $str_mobile,
        ];
        return $this->toAdd($arr_data);
    }

    /**
     * 获取司机首页信息
     */
    public function getDriverInfoList($arr_where,$int_first_row,$int_list_rows,$sort){
        $data = Db::name($this->db_name)
            ->where($arr_where)
            ->field('driver_info.id,driver_info.mobile,driver_info.real_name as realName,driver_info.license_type as licenseType,count(driver_order.driver_id) as transport,driver_info.gmt_create as gmtCreate,driver_info.state')
            ->join('driver_order','driver_order.driver_id=driver_info.id','left')
            ->limit($int_first_row,$int_list_rows)
            ->group('driver_info.id')
            ->order("driver_info.gmt_create $sort")
            ->select();
        return $data;
    }
}
